package com.chief.part2;

import com.chief.BaseBuilder;

import java.util.function.Function;

public class Director {

    public static void main(String[] args) {

        System.out.println(SecKillActivityBuilder.of(e -> e.runningPara("a5").preparePara("b5").endingPara("c5")));

        Activity activity = Director.getSecKillActivity(mapActivityBuilder -> mapActivityBuilder.preparePara("a1").endingPara("b1").runningPara("c1"));
        System.out.println(activity);

        SecKillActivityBuilder secKillActivityBuilder = new SecKillActivityBuilder();
        ActivityBuilder activityBuilder = secKillActivityBuilder.runningPara("a2").endingPara("b2").preparePara("c2");
        activity = activityBuilder.build();
        System.out.println(activity);

        activityBuilder = secKillActivityBuilder.runningPara("a3").endingPara("b3").preparePara("c3");
        activity = Director.getActivity(activityBuilder);
        System.out.println(activity);

        activity = Director.getActivity2(new SecKillActivityBuilder());
        System.out.println(activity);
    }

    public static Activity getSecKillActivity(Function<ActivityBuilder , BaseBuilder<Activity>> fn){
        return fn.apply(new SecKillActivityBuilder()).build();
    }

    public static Activity getActivity(ActivityBuilder activityBuilder){
        return activityBuilder.build();
    }

    public static Activity getActivity2(ActivityBuilder activityBuilder){
        return activityBuilder.runningPara("a4").endingPara("b4").preparePara("c4").build();
    }
}
